﻿/*!	@file	r_draw_depthstencilState.h
	@brief	深度ステンシルステート
Copyright (c) 2010 Yuya Yamaguchi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _R_DRAW_DEPTHSTENCILSTATE_H_
#define _R_DRAW_DEPTHSTENCILSTATE_H_

#include "../rtti/r_rtti_class_base.h"
#include "../math/r_math_colorRGBf.h"
#include "r_draw_def.h"
#include "../alloc/r_alloc_new_delete.h"

namespace r{
	namespace draw{
		struct DepthStencilOPDesc {
			DepthStencilOPDesc()
				:
				stencilFailOp ( StencilOp_KEEP ),
				stencilDepthFailOp ( StencilOp_KEEP ),
				stencilPassOp ( StencilOp_KEEP ),
				stencilFunc ( DepthComparisonType_ALWAYS ) {
			}
			r_ui32					stencilFailOp;			//!< ステンシルテストに失敗した場合	StencilOp
			r_ui32					stencilDepthFailOp;		//!< 深度テストに失敗した場合	StencilOp
			r_ui32					stencilPassOp;			//!< ステンシルテストに成功した場合	StencilOp
			r_ui32					stencilFunc;			//!< ステンシルテスト条件	DepthComparisonType
		};

		//! 深度ステンシルステートの定義
		struct DepthStencilStateDesc {
			DepthStencilStateDesc()
				:
				depthEnable ( true ),
				depthWriteMask ( DepthWriteMaskFlag_ALL ),
				depthFunc ( DepthComparisonType_LESS ),
				stencilEnable ( false ),
				stencilReadMask ( 0xff ),
				stencilWriteMask ( 0xff ) {
			}
			r_bool						depthEnable;		//!< 深度テストの有効無効
			r_ui32						depthWriteMask;		//!< 深度書き込みマスク	DepthWriteMaskFlag
			r_ui32						depthFunc;			//!< 深度テスト条件	DepthComparisonType
			r_bool						stencilEnable;		//!< ステンシルテスト有効無効
			r_ui8						stencilReadMask;	//!< ステンシル読み込みマスク
			r_ui8						stencilWriteMask;	//!< ステンシル書き込みマスク
			DepthStencilOPDesc	frontFace;			//!< 正面ステンシル
			DepthStencilOPDesc	backFace;			//!< 背面ステンシル
		};

		//! サンプラクラス
		/*!
		*/
		class DepthStencilState : public r::rtti::ClassBase
		{
			RRTTI_REFLECTION_DECLARE
		public:
			RALLOC_PLACEMENT_NEW_DELETE_DECLEARE
		protected:
			//! コンストラクタ
			DepthStencilState( void );
			//! デストラクタ
			virtual ~DepthStencilState( void );
		public:
			//! 生成関数
			static DepthStencilState*	create( const DepthStencilStateDesc& desc );
			//! 破棄関数
			virtual void	destroy( void );
		protected:
		private:
		};
	}
}


#endif // _R_DRAW_DEPTHSTENCILSTATE_H_
